/**
 * 筛选栏
 */

 import React,{PropTypes,Component,PureComponent}  from 'react';
 import {Button ,message ,Form,Row,Col,Card ,Select } from 'antd';
 import {connect} from 'dva';

 // import SchememFit from './schememFit';//筛选方案设置
 import PlanSelect from './PlanSelect';//方案筛选下拉框
 import { ProlistSelect ,PdtSelect} from '../../../components/ToolbarItem';

 import style from './toolbar.less';
 const FormItem = Form.Item;

//工具栏
const Option = Select.Option;
const Toolbar=({
		productList,
		lPortId,
		fundpool,
		dispatch,
		tag,
		sfkpiName,
		sfschemeid,
		sfschemename,
		pdtsearchId,
		ListPdt,
		isShow,
		ListPdt2
		})=>{
	console.log("tool>>>>>",fundpool,ListPdt2);

	const queryData=() => {
		if(lPortId === ''){
			message.warning("请选择产品!");
			return;
		}else{
			dispatch({
				type:"fundpool/pdtSelect",
				payload:{
					productId:lPortId,
					countRange:3
				}
			})
		}
	}
	/*const searchData=(v)=>{
		dispatch({
	  	type:'fundpool/getListPdt',
	  	payload:{
	  		term:pdtsearchId
	  	}
	  })
	}
	var children = [];
	if(ListPdt){
		for (let i = 0; i < ListPdt.length; i++) {
	  	children.push(
	  		<Option 
	  			key={ListPdt[i].productId} 
	  			value={`${ListPdt[i].productCode}-${ListPdt[i].productName}`}>{`${ListPdt[i].productCode}-${ListPdt[i].productName}`}
	  		</Option>
	  	);
		}
	}
	function handleChange(value) {
		if(value.length > 3){
			dispatch({
		  	type:'fundpool/setState',
		  	payload:{
		  		isShow:false
		  	}
		  }) 
		}else{
			dispatch({
		  	type:'fundpool/setState',
		  	payload:{
		  		isShow:true
		  	}
		  }) 
		}
	  dispatch({
	  	type:'fundpool/setState',
	  	payload:{
	  		pdtsearchId:value
	  	}
	  })
	}
	function SearchBtn(vb) {
		console.log('vb>>>',vb)
		if(vb.type == true){
			return (
		    <Button type="primary"  disabled>
					搜索
				</Button>
	  	);
		}else{
			return (
				<Button type="primary" onClick={searchData} >
					搜索
				</Button>
			)
		}
	}*/
	return (
		<div>
			<Row type="flex" justify="space-between" align="bottom">
				<Col>
					<Form layout="inline" className={style.pdtselect}>
						<FormItem
							label="选择产品"
						>
							{/*<Select
								mode="combobox"
						    style={{ width: 150 }}
						    placeholder="Please select"
						    onChange={handleChange}
						  >
						    {children}
						  </Select>*/}

						  <ProlistSelect
						  	dispatch={dispatch}
						  	tag={tag}
						  	data={ListPdt2}
						  	isShow={isShow}
						  	pdtsearchId={pdtsearchId}
						  />
						</FormItem>
						{/*<SearchBtn type={isShow}/>*/}
						<Button type="primary" onClick={queryData} style={{marginLeft:10}}>
							添加
						</Button>
					</Form>
				</Col>
			</Row>
			<hr style={{marginTop:5,marginBottom:8}}/>
			<Row>
				<Col>
					<PlanSelect/>
				</Col>
			</Row>
		</div>
	)
}
 Toolbar.propTypes={}
 export default connect(({fundpool})=>({fundpool}))(Toolbar)
